package com.iims.finance.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.iims.common.core.domain.BussinessEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 开票
 *
 * @TableName cmis_cw_invoice
 */
@TableName(value = "cmis_cw_invoice")
@Data
@BussinessEntity
@ApiModel("开票信息")
public class CmisCwInvoice extends CmisFinanceReview {
    /**
     * 开票Id
     */
    @ApiModelProperty(value = "开票Id", required = true)
    @TableId(type = IdType.AUTO)
    private Long invoiceId;

    @ApiModelProperty(value = "发票代码,不能超过30位", required = true)
    @Size(max = 30, message = "发票代码不能超过30位")
    @NotBlank(message = "发票号不能为空")
    private String invoiceCode;

    @ApiModelProperty(value = "发票号码,发票号码不能超过20位", required = true)
    @Size(max = 20, message = "发票代码不能超过20位")
    @NotBlank(message = "发票号不能为空")
    private String invoiceNo;

    /**
     * 合同Id
     */
    @ApiModelProperty(value = "正式合同Id", required = true)
    @Positive(message = "正式合同Id必须有效 >0")
    private Long contractId;

    /**
     * 开票人
     */
    @ApiModelProperty(value = "开票人(user_code)", required = true)
    @NotBlank(message = "开票人不能为空")
    private String invoiceUser;

    /**
     * 开票金额
     */
    @ApiModelProperty(value = "开票金额/元:最大12位整数2位小数", required = true)
    @Column(length = 14, scale = 2)
    @Positive(message = "开票金额必须有效 >0")
    private BigDecimal invoiceMoney;

    /**
     * 开票日期
     */
    @ApiModelProperty(value = "开票日期|yyyy-MM-dd", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "开票日期不能为空")
    private Date invoiceDate;

    /**
     * 寄票人
     */
    @ApiModelProperty(value = "寄票人(user_code)")
    private String poster;

    /**
     * 收票人(客户)
     */
    @ApiModelProperty(value = "收票人,中文姓名(界面打字输入)")
    private String collector;

    //vo
    @ApiModelProperty("开票人")
    @TableField(exist = false)
    private String invoiceUserCN;
}